import $store from '@/store/index.js';
//消息置顶
const handle = async(data)=>{
	try{
		const activeChatUuid = $store.state.chat.chatInfo && $store.state.chat.chatInfo.uuid || ''; // 访问根级状态的chatInfo
		if(data.is_top){
			let grouptop = {
				msg_id:data.msg_id,
				content_text:data.content_text,
				conversation_id:data.conversation_id,
				sender_id:data.sender_id,
				target_id:data.target_id,
				msg_type:data.msg_type,
			}
			$store.commit('setChatTopMsg', {
				data:grouptop,
				target_id:data.target_id
			})
			let storageGroupTop = uni.getStorageSync('chatGroupTop') || {}
			storageGroupTop[data.target_id] = grouptop
			uni.setStorageSync('chatGroupTop',storageGroupTop)
			//存储本次打开缓存过的群id,受socket连接的影响
			$store.commit('setOpenGroups',{group_id:data.target_id,type:'msgTop'})
		}else{
			$store.commit('setChatTopMsg', {
				data:null,
				target_id:data.target_id
			})
			let storageGroupTop = uni.getStorageSync('chatGroupTop') || {}
			if(storageGroupTop[data.target_id]){
				storageGroupTop[data.target_id] = null 
			}
			uni.setStorageSync('chatGroupTop',storageGroupTop)
		}
	}catch(e){
		
	}
}
export default handle